-
Notifications
You must be signed in to change notification settings - Fork 51
p-token: Add unwrap_lamports
instruction
#87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: febo/custom-entrypoint
Are you sure you want to change the base?
Conversation
fafdd3e
to
8a3de38
Compare
4409253
to
82fa3b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! Just the bit on the discriminator. Also, be sure to get someone like @Arrowana to make sure it does what they need.
It looks ok, but should it have a feature similar to close, allowing unwrapping the entire available amount? I see a few use cases for this
|
So would it make more sense to always unwrap the entire amount or have both options? |
both options |
b9cdf7c
to
369e713
Compare
@Arrowana PR updated. |
Problem
In order to transfer out lamports from native SOL accounts, currently it is necessary to create and close ATAs or token accounts all the time.
Solution
This PR adds a new
unwrap_lamports
instruction that allows transferring out lamports directly to any destination account. This eliminates the need for creating temporary native token accounts for the recipient.The new instruction uses the discriminator
39
45
, which is currently unused in Token-2022.The amount to unwrap is specified as an
Option<u64>
:None
: the entire token balance is unwrapSome(amount)
: the specified amount is unwrap